﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using EF.Model;
using EF.Model.Base;
using EF.DAL.Base;

namespace EF.BLL.Base
{
    public class FunctionService
    {
        private FunctionDAO funcDAL = new FunctionDAO();

        /// <summary>
        /// 根据角色和语言获取页面的功能点
        /// </summary>
        /// <param name="role">系统角色</param>
        /// <param name="pageId">页面Id</param>
        /// <param name="lang">语言</param>
        /// <returns>e.g(refresh:'刷新',new:'新建')</returns>
        public string GetPageFunctionPoints(string role, int pageId, string lang)
        {
            return funcDAL.GetPageFunctionPoints(role, pageId, lang);
        }

        /// <summary>
        /// 获取功能点树
        /// </summary>
        /// <param name="lang">语言</param>
        /// <returns></returns>
        public DataTable GetFunctionTree(string lang)
        {
            return funcDAL.GetFunctionTree(lang);
        }

        /// <summary>
        /// 功能新建
        /// </summary>
        /// <param name="model"></param>
        /// <param name="lang"></param>
        /// <param name="msg"></param>
        /// <returns>1,成功; 0,失败.</returns>
        public int Add(FunctionModel model, string lang, out string msg)
        {
            return funcDAL.Add(model, lang, out msg);
        }

        /// <summary>
        /// 功能编辑
        /// </summary>
        /// <param name="model"></param>
        /// <param name="lang"></param>
        /// <param name="msg"></param>
        /// <returns>1,成功; 0,失败.</returns>
        public int Edit(FunctionModel model, string lang, out string msg)
        {
            return funcDAL.Edit(model, lang, out msg);
        }

        /// <summary>
        /// 获取Model
        /// </summary>
        /// <param name="funcId">功能Id</param>
        /// <returns></returns>
        public FunctionModel GetModel(int funcId)
        {
            return funcDAL.GetModel(funcId);
        }
        
        /// <summary>
        /// 物理删除
        /// </summary>
        /// <param name="funcId"></param>
        /// <param name="lang"></param>
        /// <param name="msg"></param>
        /// <returns>1,成功; 0,失败.</returns>
        public int Delete(int funcId, string lang, out string msg)
        {
            return funcDAL.Delete(funcId, lang, out msg);
        }
    }
}
